﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JKF.BusinessLayer.BLL;
using JKF.Entities.Model;
using JKF.Substructure;

namespace JKF.Web.Customer.Swing_Card
{
    public partial class Swing_Card : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public string CustomerKey
        {
            get { return P("customerKey"); }
        }

        public string CurstomerCardNo
        {
            get { return Customer == null ? "" : Customer.CARD_NO; }
        }

        public string CustomerLevelOption
        {
            get
            {
                var builder = new StringBuilder();
                var bllLevel = new bllDIC_LEVEL();
                var levels = bllLevel.GetListArray("");
                var levelCode = Customer == null ? "" : Customer.LEVEL_CODE;
                foreach (var leveLinfo in levels)
                {
                    if (leveLinfo.LEVEL_CODE.Equals(levelCode, StringComparison.CurrentCultureIgnoreCase))
                    {
                        builder.AppendFormat("<option value=\"{0}\" selected=\"selected\">{1}</option>", leveLinfo.LEVEL_CODE, leveLinfo.NAME);
                        continue;
                    }
                    builder.AppendFormat("<option value=\"{0}\">{1}</option>", leveLinfo.LEVEL_CODE, leveLinfo.NAME);
                }
                return builder.ToString();
            }
        }

        private CUSTOMERinfo Customer
        {
            get
            {
                var key = CustomerKey;
                if (key.IsGuidB())
                {
                    var bll = new bllCUSTOMER();
                    return bll.GetModel(new Guid(key));
                }
                return null;
            }
        }
    }
}